import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PlantVO, PlantForm, PlantQuery } from '@/api/base/plant/types';

/**
 * 查询工厂信息列表
 * @param query
 * @returns {*}
 */
export const pagePlant = (query?: PlantQuery): AxiosPromise<PlantVO[]> => {
  return request({
    url: '/base/plant/page',
    method: 'get',
    params: query
  });
};

/**
 * 查询工厂信息列表
 * @param query
 * @returns {*}
 */
export const listPlant = (query?: PlantQuery): AxiosPromise<PlantVO[]> => {
  return request({
    url: '/base/plant/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询工厂信息详细
 * @param plantId
 */
export const getPlant = (plantId: string | number): AxiosPromise<PlantVO> => {
  return request({
    url: '/base/plant/' + plantId,
    method: 'get'
  });
};

/**
 * 新增工厂信息
 * @param data
 */
export const addPlant = (data: PlantForm) => {
  return request({
    url: '/base/plant',
    method: 'post',
    data: data
  });
};

/**
 * 修改工厂信息
 * @param data
 */
export const updatePlant = (data: PlantForm) => {
  return request({
    url: '/base/plant',
    method: 'put',
    data: data
  });
};

/**
 * 删除工厂信息
 * @param plantId
 */
export const delPlant = (plantId: string | number | Array<string | number>) => {
  return request({
    url: '/base/plant/' + plantId,
    method: 'delete'
  });
};
